python用matplotlib绘制饼图 python利用matplotlib库绘制饼图的方法示例(IT技术)

您所在的位置:网站首页 python matplotlib画饼图 python用matplotlib绘制饼图 python利用matplotlib库绘制饼图的方法示例(IT技术)

python用matplotlib绘制饼图 python利用matplotlib库绘制饼图的方法示例(IT技术)

#python用matplotlib绘制饼图 python利用matplotlib库绘制饼图的方法示例(IT技术)| 来源: 网络整理| 查看: 265

想了解python利用matplotlib库绘制饼图的方法示例的相关内容吗,jihite在本文为您仔细讲解python用matplotlib绘制饼图的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:python,matplotlib,matplotlib,画图,python,matplotlib教程,下面大家一起来学习吧。

介绍

matplotlib 是python最著名的绘图库,它提供了一整套和matlab相似的命令API,十分适合交互式地进行制图。而且也可以方便地将它作为绘图控件,嵌入GUI应用程序中。

它的文档相当完备,并且 Gallery页面 中有上百幅缩略图,打开之后都有源程序。因此如果你需要绘制某种类型的图,只需要在这个页面中浏览/复制/粘贴一下,基本上都能搞定。

matplotlib的安装方法可以点击这里

这篇文章给大家主要介绍了python用matplotlib绘制饼图的方法,话不多说,下面来看代码。

示例代码

import matplotlib.pyplot as plt # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' sizes = [15, 30, 45, 10] colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs') plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal') plt.savefig('D:\\pie.png') plt.show()

结果

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。

相关文章python字典键值 Python合并字典键值并去除重复元素的实例python hbase操作 python操作 hbase 数据的方法python hbase python 调用HBase的简单实例更改Ubuntu默认python版本 更改Ubuntu默认python版本的两种方法pythopython虚拟环境virualenv python虚拟环境virualenv的安装与使用python用reduce和map字符串转数字 python用reduce和map把字符串转为python微信好友删除 python查看微信好友是否删除自己Python3.5安装flask-mongoengine 库 win系统下为Python3.5安装flask-Centos用mock构建rpm Centos系统中用mock构建rpm的PHP抓取百度阅读 利用PHP抓取百度阅读的方法示例


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3